package org.arain.baseii.system.log;

import java.util.ArrayList;
import java.util.List;

import org.arain.baseii.grid.AMGrid;
import org.arain.baseii.grid.ColumnsPojo;
import org.arain.baseii.grid.QueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 
* <p>Title:SystemLogController </p>
* @author Arain
* @date2017年9月6日
 */
@Controller
@RequestMapping("system/log")
public class SystemLogController {
	@Autowired
	private SystemLogService systemLogService;
	
	@RequestMapping("list_01")
	public String list_01(Model model) {
		List<ColumnsPojo> columns = new ArrayList<>();
		AMGrid grid = new AMGrid("id");
		grid.setUrl("/system/log/load_grid.do");
		grid.setToolbar("logToolbar");
		ColumnsPojo pojo;
		pojo = new ColumnsPojo("mac", "登录系统或浏览器");
		columns.add(pojo);
		pojo = new ColumnsPojo("username", "登录用户名");
		columns.add(pojo);
		pojo = new ColumnsPojo("ip", "登录IP");
		columns.add(pojo);
		pojo = new ColumnsPojo("loginTime", "登录时间");
		columns.add(pojo);
		grid.setColumns(columns.toString());
		
		model.addAttribute("dataGrid", grid.toString());
		return "/system/log/list_01";
	}
	
	@RequestMapping(value="load_grid.do",produces="text/json;charset=UTF-8")
	@ResponseBody
	public String load_grid(QueryParam param) {
		return systemLogService.load_grid(param);
	}
	
}
